########作业
# 利用map批量检测用户名是否符合规范=> username符合规范, username不符合规范
# • 只能包含数据、字母、下划线，不以数字开头，长度在6-18之间
# import re
# a=["123","a123456","1234"]
# def func(a):
#         if re.findall(r"^[A-Za-z_]\w{5,17}",a):
#             return a+"符合规范"
#         else:
#             return a+"不符合规范"
# result=map(func,a)
# print(list(result))

#  filter把合法的用户名显示出来
# import re
# a=["123","a123456","1234"]
# def func(x):
#     # for i in a:
#     if re.match(r"[A-Za-z_]\w{5,17}",x) and 6<=len(x)<=18:
#         print(f"{x}符合规范")
#     else:
#         print(f"{x}不符合规范")
# result=filter(func,a)
# print(list(result))


#  匿名函数+reduce实现 1*2*3*...*n
# from functools import reduce
# print(reduce(lambda x,y:x*y,range(1,100)))


#  filter函数:找出[1-100]能被3整除的数
# def func(i):
#     if i%3==0:
#         return i
# result=filter(func,range(1,101))
# print(list(result))

#  map函数:求list[1-10]各项的平方
# def func(x):
#     return x*x
# result=map(func,range(1,11))
# print(list(result))

#  将列表[1,4,5,9] 转换成 '1459'的字符串
# from functools import reduce
# def func(x,y):
#     return str(x)+str(y)
# list1=[1,4,5,9]
# result=reduce(func,list1)
# print(result)
# print(type(result))

# 有以下列表：list1=[7, -8, 5, 4, 0, -2, -5]
# • 正数在前负数在后
# • 整数从小到大
# • 负数从大到小

# list1=[7,-8,5,4,0,-2,-5]
# list2=[]
# list3=[]
# list4=[]
# for i in list1:
#     if i>=0:
#         list2.append(i)
#     else:
#         list3.append(i)
# for i in (sorted(list2)):
#     list4.append(i)
# for i in (sorted(list3,key=abs)):
#     list4.append(i)
# print(list4)







#  这是一个字符串排序，排序规则：小写<大写<奇数<偶数
# • s ='asdf234GDSdsf23' #排序:小写-大写-奇数-偶数
# • 原理：先比较元组的第一个值，FALSE
from functools import reduce
s ='asdf234GDSdsf23'
lst1=[]
lst2=[]
lst3=[]
lst4=[]
for i in s:
    if i.islower():
        lst1.append(i)
    elif i.isupper():
        lst2.append(i)
    elif i.isdigit():
        if int(i)%2!=0:
            lst3.append(i)
        else:
            lst4.append(i)
s=sorted(lst1)+sorted(lst2)+sorted(lst3)+sorted(lst4)
print(reduce(lambda x,y:str(x)+str(y),s))
print(type(reduce(lambda x,y:str(x)+str(y),s)))